home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbpacket.zip / LOAN2.BAS < prev    next >
BASIC Source File  |  1991-10-05  |  3KB  |  117 lines

  1. REM LOAN PROGRAM, PART II (LOAN2.BAS)
  2.  
  3. ' This program calculates and prints the
  4. ' loan schedule.  It's a modified and updated
  5. ' version.
  6.  
  7. ' Initialization section
  8. CLS
  9. PRINT "LOAN AMORTIZATION"
  10. PRINT
  11.  
  12. ' Input section
  13. INPUT "Enter the amount of the loan", A
  14. INPUT "Enter the yearly interest rate (in %)", Rate
  15. INPUT "Input the number of years of the loan", Years
  16.  
  17. ' Change annual interest rate to monthly rate
  18. I = Rate / 12 / 100
  19.  
  20. ' Convert years to number of monthly payments
  21. N = Years * 12
  22.  
  23. ' Compute the monthly payment
  24. P = I * A * (((1 + I) ^ N) / (((1 + I) ^ N) - 1))
  25.  
  26. ' Initialize variables for the amortization schedule
  27. Ba1 = A
  28. Totint = 0
  29. Image$ = "$$#########,.##"
  30.  
  31. ' Printing the menu of choices
  32. PRINT : PRINT "MENU"
  33. PRINT
  34. PRINT "1 - Display payment data"
  35. PRINT "2 - Display amortization schedule"
  36. PRINT "3 - Print payment data and amortization schedule"
  37. PRINT "Any other number to exit"
  38. PRINT
  39. INPUT "Enter your choice   ", Choice
  40. SELECT CASE Choice
  41.  
  42. CASE 1
  43.    PRINT "The monthly payment for a loan of $"; A
  44.    PRINT "at a rate of"; Rate; "%"
  45.    PRINT "for"; Years; "years ";
  46.    PRINT "is";
  47.    PRINT USING Image$; P
  48.  
  49. CASE 2
  50.    ' Display the amortization schedule
  51.    PRINT "NUM";
  52.    PRINT TAB(13); "INTEREST";
  53.    PRINT TAB(27); "PRINCIPAL";
  54.    PRINT TAB(44); "PRIN BAL";
  55.    PRINT TAB(62); "TOT INT"
  56.    
  57.    ' Do the loop for the number of payments
  58.    FOR J = 1 TO N
  59.       ' Compute the interest
  60.       Interest = Ba1 * I
  61.       ' Compute the principal
  62.       Principal = P - Interest
  63.       ' Force out the last payment
  64.       IF J = N THEN Principal = Ba1
  65.       ' Update the loan balance
  66.       Ba1 = Ba1 - Principal
  67.       ' Update the total interest
  68.       Totint = Totint + Interest
  69.  
  70.       ' Display the monthly payment detail
  71.       PRINT J;
  72.       PRINT USING Image$; TAB(6); Interest;
  73.       PRINT USING Image$; TAB(21); Principal;
  74.       PRINT USING Image$; TAB(37); Ba1;
  75.       PRINT USING Image$; TAB(54); Totint
  76.    NEXT J
  77.  
  78. CASE 3
  79.    ' Print payment data on printer
  80.    LPRINT "NUM";
  81.    LPRINT TAB(13); "INTEREST";
  82.    LPRINT TAB(27); "PRINCIPAL";
  83.    LPRINT TAB(44); "PRIN BAL";
  84.    LPRINT TAB(62); "TOT INT"
  85.   
  86.    ' Do the loop for the number of payments
  87.    DO WHILE J <= N
  88.       ' Compute the interest
  89.       Interest = Ba1 * I
  90.       ' Compute the principal
  91.       Principal = P - Interest
  92.       ' Force out the last payment
  93.       IF J = N THEN Principal = Ba1
  94.       ' Update the loan balance
  95.       Ba1 = Ba1 - Principal
  96.       ' Update the total interest
  97.       Totint = Totint + Interest
  98.  
  99.       ' Display the monthly payment detail
  100.       LPRINT J;
  101.       LPRINT USING Image$; TAB(6); Interest;
  102.       LPRINT USING Image$; TAB(21); Principal;
  103.       LPRINT USING Image$; TAB(37); Ba1;
  104.       LPRINT USING Image$; TAB(54); Totint
  105.       J = J + 1
  106.    LOOP
  107.  
  108. CASE ELSE
  109.    PRINT "Goodbye for now!"
  110.    END
  111.  
  112. END SELECT
  113.  
  114.    
  115.  
  116.  
  117.